import unittest
from selenium import webdriver
from qinjiwei.jichufunction.login import login
from qinjiwei.jichufunction.newShiwu import newshiwu
import time

class OaDaiBanShiXixnag(unittest.TestCase):
    '''测试待发事物模块'''
    def setUp(self):
        self.driver = login()
        self.driver.implicitly_wait(5)
        newshiwu(self.driver)
        self.driver.switch_to.default_content()

    def test1(self):
        '''正向测试修改转发功能'''
        #定位代发事项元素并点击
        self.driver.find_element('xpath','/html/body/div[3]/div/div[1]/table/tbody/tr[12]/td/a').click()
        #切换到第一层frame
        self.driver.switch_to.frame(self.driver.find_element('id','iframe_main'))
        #切换到第二层frame
        self.driver.switch_to.frame(self.driver.find_element('xpath','/html/frameset/frame[1]'))
        # 勾选待发记录
        self.driver.find_element('xpath','/html/body/form[1]/div[2]/div/div[1]/div[2]/table/tbody/tr[1]/td[1]/div/input').click()
        #定位修改按钮并点击
        self.driver.find_element('xpath','/html/body/form[1]/div[1]/div[1]/button').click()
        #返回到上一级frame
        self.driver.switch_to.parent_frame()

        time.sleep(1)
        #定位立即发送按钮并点击
        self.driver.find_element('id','button_send').click()
        #返回最上层
        self.driver.switch_to.default_content()
        # 判断是否发送成功
        res = self.driver.find_element('xpath',
                                       '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]').text
        assert res == '发送成功！', '发送失败!'
        # 点击确定
        self.driver.find_element('xpath','/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[3]/td/div/input').click()

    def test2(self):
        ''''''
        pass


    def tearDown(self):
        self.driver.quit()


if __name__ == '__main__':
    unittest.main()